-
-
Notifications
You must be signed in to change notification settings - Fork 709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use GtkButton instead of GtkLabel for Modules #1120
Conversation
42cd7fb
to
21f7771
Compare
612a1a8
to
5c418fb
Compare
5c418fb
to
c2fba70
Compare
c2fba70
to
8777f3a
Compare
8777f3a
to
19b6c0f
Compare
19b6c0f
to
da17461
Compare
da17461
to
61886b3
Compare
The AButton class is designed as full a substitute to ALabel. The GtkButton attribute 'button_' is initialized with a label. This label can the be referenced by the subsequent inheritors of AButton instead of the GtkLabel attribute 'label_' of ALabel. For convenience a GtkLabel* 'label_' attribute is added to AButton. If the button cannot be clicked it is disabled, effectively acting like its label predecessor. GtkButton seems to catch one-click mouse events regardless of the flags set on it. Therefore, 'signal_pressed' is connected to a function creating a fake GdkEventButton* and calling 'handleToggle' (for details on this possible bug in GTK see: https://stackoverflow.com/questions/45334911 ) In accordance with other GtkButtons (i.e. the sway/workspace ones) set_relief(Gtk::RELIEF_NONE) is called on the 'button_' instance.
Since now modules as well as workspaces are buttons, the fix for the 'strange hover effects' has to be applied on a global level. In return there is a nice hover effect also on the modules.
Fixes issue where the class parameters in style.css would have no effect. The CSS now references the GtkButton instead of the GtkLabel. Removing all style-classes from the custom module GtkButton however removes any properties set via style.css. Thus, the default classes 'flat' and 'text-button' are added on every update of these modules.
Mouse-over tooltips set on the label only appear once the mouse hovers over exactly the label. Other apps (e.g. firefox) show the tooltip once the pointer hovers the button. Not solely its label. With this commit we get the same behaviour.
61886b3
to
2b735f4
Compare
Hi, how can I customize the hover background? I don't want my widgets which are on a black bar to turn their background to white on hovering. I tried several kinds of Affected widgets are: two customs (not all of them), idle inhibitor and pulseaudio. |
@pinselimo Can you check this issue #1726 |
@pinselimo we can have a hover effect only if in the default config, the module have a click event, otherwise we'll let the user change that according to his needs. |
@pinselimo we may have been talking about different issues. The issue I have is this: The purple text is my custom widget to show the focused window title. This widget and the bar has a black background. When I hover on the widget, it has a white background like the screenshot, and I failed to make it black (i.e. I don't want it to change on hovering). My style.css. |
Ah I see, then just add:
from the default style.css to yours. Fixes the issue for me. If you want to keep the hover effect on the workspace buttons, where it should have been before(?) also add:
|
@pinselimo thanks, it works! Actually I don't use the workspace widget because I'm using wayfire.... |
Set a default color, issue seems to have been introduced by Alexays/Waybar#1120
If anyone is looking to retain buttons until Gtk4 migration is done or whatever, use commit |
This PR turns the
GtkLabel
into aGtkButton
. This has some visual advantages::hover
qualifier can be set on modules instyle.css
Checkout my dotfiles (.config/waybar/*) for how I use this PR to distinguish modules spawning a window on click from those just changing format.
Caveats:
GtkButton
catches all single mouse button click events regardless of the flags set on it. Therefore, I had to connect itssignal_pressed
method to the underlying, precedinghandleToggle
method.Another workaround would have been to connect
handelToggle
tosignal_button_release_event
instead ofsignal_button_press_event
inAModule
. I've done that in my 'use_gtk_button' (without the '_v2') branch. The implementation of '_v2' mimics the previous behavior much better though.Thanks :)